package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class PivotItemCollection {
   PivotField a;
   ArrayList b;

   PivotItemCollection(PivotField pivotField) {
      this.a = pivotField;
      this.b = new ArrayList();
   }

   int a(PivotItem var1) {
      com.aspose.cells.b.a.a.ze.a(this.b, (Object)var1);
      return this.getCount() - 1;
   }

   public PivotItem get(int index) {
      return (PivotItem)this.b.get(index);
   }

   public PivotItem get(String itemValue) {
      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         Object var3 = this.get(var2).getValue();
         if (var3 == null) {
            if (itemValue == null) {
               return this.get(var2);
            }
         } else if (com.aspose.cells.b.a.zr.a(var3).equals(itemValue)) {
            return this.get(var2);
         }
      }

      return null;
   }

   public int getCount() {
      return this.b.size();
   }

   void a(int var1) {
      this.b.remove(var1);
   }

   int a() {
      int var1 = 0;
      Iterator var2 = this.b.iterator();

      while(var2.hasNext()) {
         PivotItem var3 = (PivotItem)var2.next();
         if (var3.isHidden()) {
            ++var1;
         }
      }

      return var1;
   }

   public void changeitemsOrder(int sourceIndex, int destIndex) {
      Object var3 = this.b.get(destIndex);
      Object var4 = this.b.get(sourceIndex);
      this.b.set(destIndex, var4);
      this.b.set(sourceIndex, var3);
   }

   void a(int var1, int var2) {
      Object var3 = this.b.get(var1);
      this.b.add(var2 + 1, var3);
      this.b.remove(var1);
   }

   void b(int var1, int var2) {
      Object var3 = this.b.get(var1);
      this.b.add(var2, var3);
      this.b.remove(var1 + 1);
   }

   int b(PivotItem var1) {
      int var2 = -1;
      Iterator var3 = this.b.iterator();

      PivotItem var4;
      do {
         if (!var3.hasNext()) {
            return -1;
         }

         var4 = (PivotItem)var3.next();
         ++var2;
      } while(var1 != var4);

      return var2;
   }

   void a(zqa var1) throws Exception {
      zbrv var2 = new zbrv();
      Iterator var3 = this.b.iterator();

      while(var3.hasNext()) {
         PivotItem var4 = (PivotItem)var3.next();
         var2.a(var4);
         var2.a(var1);
      }

      PivotField var6 = this.a;
      if (var6.isAutoSubtotals() && (var6.b.a & '\uffff' & 1) != 0) {
         var2.a((short)1, 0, 65535, (String)null);
         var2.a(var1);
      } else if (!var6.getSubtotals(0)) {
         int var7 = var6.b.a;

         for(int var5 = 1; var5 < 14; ++var5) {
            if (((var7 & '\uffff') >> var5 & 1) != 0) {
               var2.a((short)(var5 + 1), 0, 65535, (String)null);
               var2.a(var1);
            }
         }

      }
   }
}
